home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / drdobbs / 1992 / 06 / dflt12 / spinbutt.c < prev    next >
Text File  |  1992-04-22  |  2KB  |  47 lines

  1. /* ------------ spinbutt.c ------------- */
  2.  
  3. #include "dflat.h"
  4.  
  5. int SpinButtonProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
  6. {
  7.     int rtn;
  8.     CTLWINDOW *ct = GetControl(wnd);
  9.     if (ct != NULL)    {
  10.         switch (msg)    {
  11.             case CREATE_WINDOW:
  12.                 wnd->wd -= 2;
  13.                 wnd->rc.rt -= 2;
  14.                 break;
  15.             case SETFOCUS:
  16.                 rtn = BaseWndProc(SPINBUTTON, wnd, msg, p1, p2);
  17.                 if (!(int)p1)
  18.                     SendMessage(NULL, HIDE_CURSOR, 0, 0);
  19.                 SetFocusCursor(wnd);
  20.                 return rtn;
  21.             case PAINT:
  22.                 foreground = FrameForeground(wnd);
  23.                 background = FrameBackground(wnd);
  24.                 wputch(wnd,UPSCROLLBOX,WindowWidth(wnd), 0);
  25.                 wputch(wnd,DOWNSCROLLBOX,WindowWidth(wnd)+1,0);
  26.                 SetFocusCursor(wnd);
  27.                 break;
  28.             case LEFT_BUTTON:
  29.                 if (p1 == GetRight(wnd) + 1)
  30.                     SendMessage(wnd, KEYBOARD, UP, 0);
  31.                 else if (p1 == GetRight(wnd) + 2)
  32.                     SendMessage(wnd, KEYBOARD, DN, 0);
  33.                 if (wnd != inFocus)
  34.                     SendMessage(wnd, SETFOCUS, TRUE, 0);
  35.                 return TRUE;
  36.             case LB_SETSELECTION:
  37.                 rtn = BaseWndProc(SPINBUTTON, wnd, msg, p1, p2);
  38.                 wnd->wtop = (int) p1;
  39.                 SendMessage(wnd, PAINT, 0, 0);
  40.                 return rtn;
  41.             default:
  42.                 break;
  43.         }
  44.     }
  45.     return BaseWndProc(SPINBUTTON, wnd, msg, p1, p2);
  46. }
  47.